package com.ljtxxhwj.myblob.service.impl;

import com.ljtxxhwj.myblob.entity.FavoriteFolderHasFavorite;
import com.ljtxxhwj.myblob.mapper.FavoriteFolderHasFavoriteMapper;
import com.ljtxxhwj.myblob.service.FavoriteFolderHasFavoriteService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class FavoriteFolderHasFavoriteServiceImpl implements FavoriteFolderHasFavoriteService {

    private final FavoriteFolderHasFavoriteMapper favoriteFolderHasFavoriteMapper;

    @Autowired
    public FavoriteFolderHasFavoriteServiceImpl(FavoriteFolderHasFavoriteMapper favoriteFolderHasFavoriteMapper) {
        this.favoriteFolderHasFavoriteMapper = favoriteFolderHasFavoriteMapper;
    }

    @Override
    public void addFavoriteFolderHasFavorite(FavoriteFolderHasFavorite relation) {
        favoriteFolderHasFavoriteMapper.insertFavoriteFolderHasFavorite(relation);
    }

    @Override
    public void removeFavoritesByFavoriteFolderId(Integer favoriteFolderId) {
        favoriteFolderHasFavoriteMapper.deleteFavoritesByFavoriteFolderId(favoriteFolderId);
    }

    @Override
    public void removeFavoriteFoldersByFavoriteId(Integer favoriteId) {
        favoriteFolderHasFavoriteMapper.deleteFavoriteFoldersByFavoriteId(favoriteId);
    }

    @Override
    public List<Integer> getFavoriteIdsByFavoriteFolderId(Integer favoriteFolderId) {
        return favoriteFolderHasFavoriteMapper.selectFavoriteIdsByFavoriteFolderId(favoriteFolderId);
    }

    @Override
    public List<Integer> getFavoriteFolderIdsByFavoriteId(Integer favoriteId) {
        return favoriteFolderHasFavoriteMapper.selectFavoriteFolderIdsByFavoriteId(favoriteId);
    }
}